package com.geekjob1120.geekjob1120pay.support;

import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.geekjob1120.geekjob1120pay.modle.PayWay;
import org.springframework.boot.jackson.JsonComponent;

import java.io.IOException;

@JsonComponent
public class PayWayDeSerializer extends StdDeserializer<PayWay> {
    public PayWayDeSerializer() {
        super(PayWay.class);
    }

    @Override
    public PayWay deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JacksonException {
        return PayWay.getByCode(p.getText());
    }
}
